]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Add unminimize effect
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 27 Feb 2015 11:13:26 +0000 (12:13 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 27 Feb 2015 12:02:19 +0000 (13:02 +0100)
The effect was added to mutter a while ago, but never implemented
in the shell. Just do the reverse of the minimize animation ...

https://bugzilla.gnome.org/show_bug.cgi?id=702662

js/ui/windowManager.js
src/gnome-shell-plugin.c
src/shell-wm-private.h
src/shell-wm.c
src/shell-wm.h

index e0bf007aaad6a77d4884155ded314bcaa6c3f502..2691cdb7a217602c1e6addac0091881f8231680f 100644 (file)
@@ -616,6 +616,7 @@ const WindowManager = new Lang.Class({
         this._shellwm =  global.window_manager;
 
         this._minimizing = [];
+        this._unminimizing = [];
         this._maximizing = [];
         this._unmaximizing = [];
         this._mapping = [];
@@ -641,6 +642,7 @@ const WindowManager = new Lang.Class({
         this._shellwm.connect('hide-tile-preview', Lang.bind(this, this._hideTilePreview));
         this._shellwm.connect('show-window-menu', Lang.bind(this, this._showWindowMenu));
         this._shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
+        this._shellwm.connect('unminimize', Lang.bind(this, this._unminimizeWindow));
         this._shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
         this._shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
         this._shellwm.connect('map', Lang.bind(this, this._mapWindow));
@@ -1072,6 +1074,84 @@ const WindowManager = new Lang.Class({
         }
     },
 
+    _unminimizeWindow : function(shellwm, actor) {
+        let types = [Meta.WindowType.NORMAL,
+                     Meta.WindowType.MODAL_DIALOG,
+                     Meta.WindowType.DIALOG];
+        if (!this._shouldAnimateActor(actor, types)) {
+            shellwm.completed_unminimize(actor);
+            return;
+        }
+
+        this._unminimizing.push(actor);
+
+        if (actor.meta_window.is_monitor_sized()) {
+            actor.opacity = 0;
+            actor.set_scale(1.0, 1.0);
+            Tweener.addTween(actor,
+                         { opacity: 255,
+                           time: MINIMIZE_WINDOW_ANIMATION_TIME,
+                           transition: 'easeOutQuad',
+                           onComplete: this._unminimizeWindowDone,
+                           onCompleteScope: this,
+                           onCompleteParams: [shellwm, actor],
+                           onOverwrite: this._unminimizeWindowOverwritten,
+                           onOverwriteScope: this,
+                           onOverwriteParams: [shellwm, actor]
+                         });
+        } else {
+            let [success, geom] = actor.meta_window.get_icon_geometry();
+            if (success) {
+                actor.set_position(geom.x, geom.y);
+                actor.set_scale(geom.width / actor.width,
+                                geom.height / actor.height);
+            } else {
+                let monitor = Main.layoutManager.monitors[actor.meta_window.get_monitor()];
+                actor.set_position(monitor.x, monitor.y);
+                if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
+                    actor.x += monitor.width;
+                actor.set_scale(0, 0);
+            }
+
+            let rect = actor.meta_window.get_frame_rect();
+            let [xDest, yDest] = [rect.x, rect.y];
+
+            actor.show();
+            Tweener.addTween(actor,
+                             { scale_x: 1.0,
+                               scale_y: 1.0,
+                               x: xDest,
+                               y: yDest,
+                               time: MINIMIZE_WINDOW_ANIMATION_TIME,
+                               transition: 'easeInExpo',
+                               onComplete: this._unminimizeWindowDone,
+                               onCompleteScope: this,
+                               onCompleteParams: [shellwm, actor],
+                               onOverwrite: this._unminimizeWindowOverwritten,
+                               onOverwriteScope: this,
+                               onOverwriteParams: [shellwm, actor]
+                             });
+        }
+    },
+
+    _unminimizeWindowDone : function(shellwm, actor) {
+        if (this._removeEffect(this._unminimizing, actor)) {
+            Tweener.removeTweens(actor);
+            actor.set_scale(1.0, 1.0);
+            actor.set_opacity(255);
+            actor.set_pivot_point(0, 0);
+
+            shellwm.completed_unminimize(actor);
+        }
+    },
+
+    _unminimizeWindowOverwritten : function(shellwm, actor) {
+        if (this._removeEffect(this._unminimizing, actor)) {
+            shellwm.completed_unminimize(actor);
+        }
+    },
+
+
     _maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
         shellwm.completed_maximize(actor);
     },
index 9c52a63fcaf5897daae84281c80e0d9042f7ac2e..a7266ef7dc0a157fbaf4ce4784b4b443730c1f29 100644 (file)
@@ -40,6 +40,8 @@
 static void gnome_shell_plugin_start            (MetaPlugin          *plugin);
 static void gnome_shell_plugin_minimize         (MetaPlugin          *plugin,
                                                  MetaWindowActor     *actor);
+static void gnome_shell_plugin_unminimize       (MetaPlugin          *plugin,
+                                                 MetaWindowActor     *actor);
 static void gnome_shell_plugin_maximize         (MetaPlugin          *plugin,
                                                  MetaWindowActor     *actor,
                                                  gint                 x,
@@ -131,6 +133,7 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
   plugin_class->start            = gnome_shell_plugin_start;
   plugin_class->map              = gnome_shell_plugin_map;
   plugin_class->minimize         = gnome_shell_plugin_minimize;
+  plugin_class->unminimize       = gnome_shell_plugin_unminimize;
   plugin_class->maximize         = gnome_shell_plugin_maximize;
   plugin_class->unmaximize       = gnome_shell_plugin_unmaximize;
   plugin_class->destroy          = gnome_shell_plugin_destroy;
@@ -268,6 +271,15 @@ gnome_shell_plugin_minimize (MetaPlugin         *plugin,
 
 }
 
+static void
+gnome_shell_plugin_unminimize (MetaPlugin         *plugin,
+                               MetaWindowActor    *actor)
+{
+  _shell_wm_unminimize (get_shell_wm (),
+                      actor);
+
+}
+
 static void
 gnome_shell_plugin_maximize (MetaPlugin         *plugin,
                              MetaWindowActor    *actor,
index 9e44b33186ab81fbdcfbd81ec4f9ec3b9297b530..de260f2f5a040ad83371bb7eba1e8545c1713434 100644 (file)
@@ -10,6 +10,8 @@ G_BEGIN_DECLS
 
 void _shell_wm_minimize   (ShellWM         *wm,
                            MetaWindowActor *actor);
+void _shell_wm_unminimize (ShellWM         *wm,
+                           MetaWindowActor *actor);
 void _shell_wm_maximize   (ShellWM         *wm,
                            MetaWindowActor *actor,
                            gint             x,
index 67d03b8ccf0397bc6d93e56fd0c98d5fa12bc978..4b58df6c593260968faa86dc097327876360c589 100644 (file)
@@ -19,6 +19,7 @@ struct _ShellWM {
 enum
 {
   MINIMIZE,
+  UNMINIMIZE,
   MAXIMIZE,
   UNMAXIMIZE,
   MAP,
@@ -65,6 +66,14 @@ shell_wm_class_init (ShellWMClass *klass)
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 1,
                   META_TYPE_WINDOW_ACTOR);
+  shell_wm_signals[UNMINIMIZE] =
+    g_signal_new ("unminimize",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 1,
+                  META_TYPE_WINDOW_ACTOR);
   shell_wm_signals[MAXIMIZE] =
     g_signal_new ("maximize",
                   G_TYPE_FROM_CLASS (klass),
@@ -197,6 +206,20 @@ shell_wm_completed_minimize (ShellWM         *wm,
   meta_plugin_minimize_completed (wm->plugin, actor);
 }
 
+/**
+ * shell_wm_completed_unminimize:
+ * @wm: the ShellWM
+ * @actor: the MetaWindowActor actor
+ *
+ * The plugin must call this when it has completed a window unminimize effect.
+ **/
+void
+shell_wm_completed_unminimize (ShellWM         *wm,
+                               MetaWindowActor *actor)
+{
+  meta_plugin_unminimize_completed (wm->plugin, actor);
+}
+
 /**
  * shell_wm_completed_maximize:
  * @wm: the ShellWM
@@ -328,6 +351,13 @@ _shell_wm_minimize (ShellWM         *wm,
   g_signal_emit (wm, shell_wm_signals[MINIMIZE], 0, actor);
 }
 
+void
+_shell_wm_unminimize (ShellWM         *wm,
+                      MetaWindowActor *actor)
+{
+  g_signal_emit (wm, shell_wm_signals[UNMINIMIZE], 0, actor);
+}
+
 void
 _shell_wm_maximize (ShellWM         *wm,
                     MetaWindowActor *actor,
index 778af523ea727e02c0ff21816ab9814c8379867c..7cd8948d88c89ca33f4b2ffba5781dc7418d4971 100644 (file)
@@ -29,6 +29,8 @@ ShellWM *shell_wm_new                        (MetaPlugin      *plugin);
 
 void     shell_wm_completed_minimize         (ShellWM         *wm,
                                               MetaWindowActor *actor);
+void     shell_wm_completed_unminimize       (ShellWM         *wm,
+                                              MetaWindowActor *actor);
 void     shell_wm_completed_maximize         (ShellWM         *wm,
                                               MetaWindowActor *actor);
 void     shell_wm_completed_unmaximize       (ShellWM         *wm,